<?php

namespace App\Listeners;

//use Illuminate\Support\Facades\Redis;
use App\Events\UpdatePermissionEvent;

class ResetPermissionCache
{
    /**
     * 创建事件监听器
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * 处理事件
     *
     * @param  \App\Events\UpdatePermissionEvent  $event
     * @return void
     */
    public function handle(UpdatePermissionEvent $event)
    {   
        $staff = \Auth::guard('admin')->user();

        if(!!$event->permission){
            if( $staff->supervisor() ){
                \Cache::forget(CACHE_PERMISSION_P); 
            }
            else{
                \Cache::forget(CACHE_PERMISSION_N.'.'.$staff->id); 
            }
                       
        }
    }
}
